package week3.day18;

/**
 * @Author fengzihao
 * @Date 2024-05-02 19:40
 */
public class CountJavaWords {
    public static void main(String[] args) {
        String str = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.indexOf("java",i)==-1)
                break;
            if ("java".equals(str.substring(i,i+4)))
                count++;
        }
        System.out.println("count = " + count);
    }
}
